package com.itboye.ihomebank.myzhujia.qianbao;

import java.util.Observable;
import java.util.Observer;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseOtherActivity;
import com.itboye.ihomebank.bean.ResultEntity;
import com.itboye.ihomebank.constants.SPContants;
import com.itboye.ihomebank.presenter.UserPresenter;
import com.itboye.ihomebank.util.ByAlert;
import com.itboye.ihomebank.util.OnPasswordInputFinish;
import com.itboye.ihomebank.util.PasswordView;
import com.itboye.ihomebank.util.SPUtils;

/**
 * 忘记原支付密码(3.填写支付密码)
 * 
 */
public class ActivityWangJiPassThree extends BaseOtherActivity implements Observer{
	TextView add_shap_title_tv;
	ImageView close_icon;

	PasswordView pwdView;// 支付密码
	
	String paypent_pass;
	
	UserPresenter userPresenter;
	
	String uid;

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub

	}

	@Override
	protected int layout_id() {
		// TODO Auto-generated method stub
		return R.layout.activity_wangji_pass03;
	}

	@Override
	protected void onInitController() {
		final PasswordView pwdView = (PasswordView) findViewById(R.id.pwd_view);

		// 添加密码输入完成的响应
		pwdView.setOnFinishInput(new OnPasswordInputFinish() {
			@Override
			public void inputFinish() {
				// 输入完成后跳转
				// 也就是说——>实现你的交易逻辑什么的在这里写
				
				userPresenter.updataZhiFu(uid, "", pwdView.getStrPassword());
				
			}
		});

	}

	@Override
	protected void onInit() {
		add_shap_title_tv.setText("重置支付密码");

		uid=(String)SPUtils.get(this, null, SPContants.USER_ID, "");
		
		userPresenter=new UserPresenter(this);
	}

	@Override
	protected void onReadIntent(Bundle bundle) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(Observable observable, Object data) {
		ResultEntity entity = handlerError(data);
		
		if (entity != null) {
			if (entity.getEventType() == UserPresenter.zhiFuPass_success) {
				ByAlert.alert(entity.getData());
				
				SPUtils.put(this, null,SPContants.IS_ZHIFU_PASS, true);
						
				finish();	
			}
			if (entity.getEventType() == UserPresenter.zhiFuPass_fail) {
				ByAlert.alert(entity.getData());
			
			}
		}	
		
		
	}
}
